﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace QuanLyNhaSach.DataAccessLayer
{
    public class CongNoDAO
    {
        DataConnection dt_con = new DataConnection();
        public CongNoDAO()
        {

        }
        public DataTable LayDanhSach()
        {
            return dt_con.Read("select * from CONGNO");
        }

        public void ThemPhieuCongNo(string maCN, string ngayLap)
        {
            string cmd = "exec TONKHO_insert '{0}','{1}'";
            dt_con.Write(String.Format(cmd, maCN, ngayLap));
        }

        public void ThemCTNO(string maCN, string maKH, int noDau, int phatSinh, int noCuoi)
        {
            string cmd = "exec CTNS_insert '{0}', '{1}', {2}, {3}, {4}";
            dt_con.Write(String.Format(cmd, maCN, maKH, noDau, phatSinh, noCuoi));
        }

        public DataTable LayBaoCaoCongNo(string thangbc)
        {
            string cmd = "exec CONGNO_Get '" + thangbc + "'";
            return dt_con.Read(String.Format(cmd));
        }
    }
}
